package cn.qingyun.gis.modules.takeaway.controller;

import cn.qingyun.gis.common.Result;
import cn.qingyun.gis.modules.takeaway.service.ITakeawayDataInitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/app/takeaway/init")
@Api(value = "数据初始化", tags = {"数据初始化"})
public class TakeawayDataInitController {
    @Resource
    private ITakeawayDataInitService iTakeawayDataInitService;

    @ApiOperation(value = "初始化外卖地址信息匹配结果表.xlsx")
    @PostMapping("/initExcelData")
    public Result<?> initExcelData(@RequestParam("file") MultipartFile file) {
        iTakeawayDataInitService.initExcelData(file);
        return Result.okData("正在初始化外卖地址信息匹配数据, 请稍后");
    }

    @ApiOperation(value = "对外卖地址信息进行格式化")
    @GetMapping("/formatting")
    public Result<?> formatting() {
        iTakeawayDataInitService.formatting();
        return Result.okData("正在格式化垂类地址信息, 请稍后");
    }

    @ApiOperation(value = "根据工号权限导出全量外卖地址数据")
    @GetMapping("/exportTakeawayTotal")
    public Result<?> exportTakeawayTotal(HttpServletRequest request) {
        iTakeawayDataInitService.exportTakeawayTotal(request);
        return Result.okData("正在导出外卖全量地址数据, 请稍后");
    }
}
